import { GSprite } from "../../../../com/mui/controls/GSprite";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { FontUtil } from "../../../common/font/FontUtil";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
import { ResFileConst } from "../../resource/ResFileConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { ImgBtn } from "../copy/btn/ImgBtn";
import { SecTimerView } from "../common/SecTimerView";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class CountryPreciousPanel
    
    export  class CountryPreciousPanel extends GSprite
    {
        constructor()
        {
            super();
            this.initView();
            return;
        }

        public set produceCoin(arg1: int)
        {
            this._txtProduceCoin.text = Language.getStringByParam(80427, arg1.toString());
            return;
        }

        public set produceYB(arg1: int)
        {
            this._txtProduceYB.text = Language.getStringByParam(80426, arg1.toString());
            return;
        }

        public set nextOpenDate(arg1: int)
        {
            this._txtNextOpenDate.setLeftTime(arg1);
            return;
        }

        public set currentCountryGold(arg1: int)
        {
            this._txtCurrent.text = arg1.toString();
            return;
        }

        public setOpenMode(arg1: int): void
        {
            this._openMode = arg1;
            this._txtOpenStatus.visible = true;
            if (arg1 != CountryPreciousPanel.OpenMode_CountDown) 
            {
                if (arg1 != CountryPreciousPanel.OpenMode_Close) 
                {
                    if (arg1 != CountryPreciousPanel.OpenMode_CanOpen) 
                    {
                        if (arg1 != CountryPreciousPanel.OpenMode_Opening) 
                        {
                            if (arg1 == CountryPreciousPanel.OpenMode_Test) 
                            {
                                this._txtNextOpenDate.visible = false;
                                this._txtOpenStatus.text = Language.getString(80437);
                            }
                        }
                        else 
                        {
                            this._txtNextOpenDate.visible = false;
                            this._txtOpenStatus.text = Language.getString(80431);
                        }
                    }
                    else 
                    {
                        this._txtNextOpenDate.visible = false;
                        this._txtOpenStatus.text = Language.getString(80430);
                    }
                }
                else 
                {
                    this._txtNextOpenDate.visible = false;
                    this._txtOpenStatus.text = Language.getString(80432);
                }
            }
            else 
            {
                this._txtNextOpenDate.visible = true;
                this._txtOpenStatus.visible = false;
            }
            return;
        }

        /* internal  */clickHelpHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CountryMoneyShowPreciousHelp));
            return;
        }

        /* internal  */clickLastRankHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CountryMoneyShowLastRank));
            return;
        }

        /* internal  */clickEnterHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._openMode == CountryPreciousPanel.OpenMode_CountDown) 
            {
                Language.getString(80435);
                return;
            }
            if (this._openMode != CountryPreciousPanel.OpenMode_CanOpen) 
            {
                if (this._openMode == CountryPreciousPanel.OpenMode_Opening) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.CountryMoneyEnterReq));
                }
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CountryMoneyOpenReq));
            }
            return;
        }

        /* internal  */gotCountryResHandler(): void
        {
            this._bmpYB.bitmapData = GlobalClass.getBitmapData(ImagesConst.CountryMoneyGold);
            this._bmpBox.bitmapData = GlobalClass.getBitmapData(ImagesConst.CountryMoneyBox);
            this._bmpCoin.bitmapData = GlobalClass.getBitmapData(ImagesConst.CountryMoneyCion);
            this._bmpNextOpenDate.bitmapData = GlobalClass.getBitmapData(ImagesConst.CountryMoneyNextOpenDate);
            return;
        }

        /* internal  */initView(): void
        {
            ObjCreate.createBg(0, 0, 757, 287, this);
            ObjCreate.createBg(0, 290, 757, 135, this);
            var loc1=GlobalStyle.textFormat1;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._txtTips = ObjCreate.createGTextField("", 0, 17, 640, 20, this, loc1);
            this._txtTips.htmlText = HTMLUtil.addColor(Language.getString(80421), GlobalStyle.color5);
            this._txtLastRank = ObjCreate.createGTextField("", 645, 17, 200, 20, this);
            this._txtLastRank.htmlText = Language.getString(80422);
            ObjCreate.createBg(5, 40, 720, 1, this, ImagesConst.SplitLine);
            var loc2=ObjCreate.createBitmap(null, 21, 49, this);
            LoaderHelp.setBitmapdata(ImagesConst.CountryMoney_CurrentGold + ".swf", loc2);
            var loc3=GlobalStyle.textFormat6;
            loc3.size = 24;
            loc3.align = flash.text.TextFormatAlign.CENTER;
            loc3.font = FontUtil.xingkaiName;
            this._txtCurrent = ObjCreate.createGTextField("", 20, 238, 270, 40, this, loc3);
            loc2 = ObjCreate.createBitmap(null, 295, 113, this);
            LoaderHelp.setBitmapdata(ImagesConst.CountryMoney_VS + ".swf", loc2);
            loc2 = ObjCreate.createBitmap(null, 463, 49, this);
            LoaderHelp.setBitmapdata(ImagesConst.CountryMoney_CanProduce + ".swf", loc2);
            loc3 = GlobalStyle.textFormat2;
            loc3.size = 15;
            ObjCreate.createBitmap(ImagesConst.PackItemBg, 516, 100, this);
            this._bmpYB = ObjCreate.createBitmap(null, 519, 103, this);
            this._txtProduceYB = ObjCreate.createGTextField("", 556, 110, 170, 20, this, loc3);
            ObjCreate.createBitmap(ImagesConst.PackItemBg, 516, 154, this);
            this._bmpCoin = ObjCreate.createBitmap(null, 519, 157, this);
            this._txtProduceCoin = ObjCreate.createGTextField("", 556, 164, 170, 20, this, loc3);
            ObjCreate.createBitmap(ImagesConst.PackItemBg, 516, 208, this);
            this._bmpBox = ObjCreate.createBitmap(null, 519, 211, this);
            this._txtProduceBox = ObjCreate.createGTextField("", 556, 218, 170, 20, this, loc3);
            ObjCreate.createBg(117, 295, 517, 40, this, ImagesConst.RemainningTimeBg);
            this._bmpNextOpenDate = ObjCreate.createBitmap(null, 152, 307, this);
            loc3 = GlobalStyle.textFormat6;
            loc3.color = GlobalStyle.color9Uint;
            loc3.size = 24;
            loc3.font = FontUtil.defaultName;
            this._txtNextOpenDate = ObjCreate.createSecTimeView(Language.getString(80425), 400, 304, 250, 30, this, loc3);
            loc3.color = GlobalStyle.color5Uint;
            this._txtOpenStatus = ObjCreate.createGTextField("", 418, 304, 250, 30, this, loc3);
            this._btnHelp = ObjCreate.createImgBtn(ImagesConst.RuleExplain, 670, 307, 60, 23, this, "Button");
            ToolTipsManager.register(this._btnHelp, null, Language.getString(80455));
            this._bmpBg0 = ObjCreate.createBitmap(null, 255, 336, this);
            LoaderHelp.setBitmapdata(ImagesConst.CountryMoneyBtnBg + ".swf", this._bmpBg0);
            this._btnOpen_Enter = ObjCreate.createGLoadedButton(ResFileConst.IntegralShopBtn, 339, 373, 150, 46, this);
            this._bmpOpen_Enter = ObjCreate.createBitmap(null, 352, 382, this);
            this._btnOpen_Enter.addEventListener(flash.events.MouseEvent.CLICK, this.clickEnterHandler);
            this._txtLastRank.addEventListener(flash.events.TextEvent.LINK, this.clickLastRankHandler);
            this._btnHelp.addEventListener(flash.events.MouseEvent.CLICK, this.clickHelpHandler);
            LoaderHelp.addResCallBack(ResFileConst.countryMoney, this.gotCountryResHandler);
            return;
        }

        /* internal  */setEnterLabel(): void
        {
            this._bmpOpen_Enter.bitmapData = GlobalClass.getBitmapData(this._enterLabelName);
            return;
        }

        public setBtnLabel(arg1: string, arg2: Boolean=false): void
        {
            this._enterLabelName = arg1;
            LoaderHelp.addResCallBack(ResFileConst.countryMoney, this.setEnterLabel);
            if (arg2) 
            {
                this._bmpOpen_Enter.filters = [];
                this._btnOpen_Enter.filters = [];
            }
            else 
            {
                this._bmpOpen_Enter.filters = [FilterConst.colorFilter];
                this._btnOpen_Enter.filters = [FilterConst.colorFilter];
            }
            return;
        }

        public set produceBox(arg1: int)
        {
            this._txtProduceBox.text = Language.getStringByParam(80428, arg1.toString());
            return;
        }

        public static /* const */OpenMode_CountDown: int=0;

        public static /* const */OpenMode_CanOpen: int=1;

        public static /* const */OpenMode_Opening: int=2;

        public static /* const */OpenMode_Close: int=3;

        public static /* const */OpenMode_Test: int=4;

        /* internal */ /* var */_txtTips: GTextFiled;

        /* internal */ /* var */_txtLastRank: GTextFiled;

        /* internal */ /* var */_txtCurrent: GTextFiled;

        /* internal */ /* var */_txtProduceYB: GTextFiled;

        /* internal */ /* var */_bmpBg0: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_btnHelp: ImgBtn;

        /* internal */ /* var */_txtNextOpenDate: SecTimerView;

        /* internal */ /* var */_bmpNextOpenDate: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpBox: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtProduceBox: GTextFiled;

        /* internal */ /* var */_bmpCoin: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtProduceCoin: GTextFiled;

        /* internal */ /* var */_bmpYB: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtOpenStatus: GTextFiled;

        /* internal */ /* var */_enterLabelName: string="CountryMoneyOpenPrecious";

        /* internal */ /* var */_bmpOpen_Enter: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_btnOpen_Enter: GLoadedButton;

        /* internal */ /* var */_openMode: int=0;
    }
